package com.lzy.product.service.impl;

import com.lzy.framework.core.utils.DozerUtils;
import com.lzy.product.dao.AgentProductProjectMapperExt;
import com.lzy.product.dtos.agent.AgentProductProjectDto;
import com.lzy.product.entity.AgentProductProject;
import com.lzy.product.service.AgentProductProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AgentProductProjectServiceImpl implements AgentProductProjectService {

    @Autowired
    private AgentProductProjectMapperExt agentProductProjectMapperExt;

    @Override
    public Long insert(AgentProductProjectDto dto) {
        AgentProductProject agentProductProject = DozerUtils.map(dto, AgentProductProject.class);
        return agentProductProjectMapperExt.insertSelective(agentProductProject) > 0 ? agentProductProject.getId() : 0;
    }

    @Override
    public Boolean update(AgentProductProjectDto dto) {
        return agentProductProjectMapperExt.updateByPrimaryKeySelective(DozerUtils.map(dto, AgentProductProject.class)) > 0;
    }

    @Override
    public Boolean delete(Long id) {
        return null;
    }

    @Override
    public Boolean remove(Long id) {
        return null;
    }

    @Override
    public AgentProductProjectDto findById(Long id) {
        return DozerUtils.map(agentProductProjectMapperExt.selectByPrimaryKey(id), AgentProductProjectDto.class);
    }

    @Override
    public List<AgentProductProjectDto> query(AgentProductProjectDto dto) {
        return agentProductProjectMapperExt.query(dto);
    }

    @Override
    public List<AgentProductProjectDto> queryAgentProductProject(Long serial_id,Integer model) {
        return agentProductProjectMapperExt.queryAgentProductProject(serial_id,model);
    }

    @Override
    public Boolean deleteByProtocolId(Long protocolId,Integer model) {
        return agentProductProjectMapperExt.deleteByProtocolId(protocolId,model);
    }

    @Override
    public List<AgentProductProjectDto> selectByOrderId(Long orderId) {
        return agentProductProjectMapperExt.selectByOrderId(orderId);
    }
}
